package com.littlebee.storychild.ui;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;

/**
 * ViewPager适配器
 * Created by liaoyong on 2016/5/4.
 */
public class TabPageIndicatorAdapter extends FragmentPagerAdapter {
    private ArrayList<Fragment> mFragmentList;
    private String[] mTitles;
    public TabPageIndicatorAdapter(FragmentManager fm, ArrayList<Fragment> fragmentList, String[] titles) {
        super(fm);
        mFragmentList = fragmentList;
        mTitles = titles;
    }

    @Override
    public Fragment getItem(int position) {
        return mFragmentList.get(position);
    }

    @Override
    public int getCount() {
        return mFragmentList.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles[position % mTitles.length];
    }
}
